home *** CD-ROM | disk | FTP | other *** search
- // ADP Auto Fix - Close AOL Script
- // Copyright (c) GTek Technologies Ltd.
-
- //======== Declarations =================================================================
- var closeUtil = new closeAolUtil();
- var dispUtil = new userDisplay();
-
- var excuteTimeout;
- var sLastEvent = "";
-
- var bWaitMsg = false;
- var bStrauss;
- var bSysTray = false;
- var bStraussOnline = false;
- var bAbortedClose = false;
- var nApiCloseValid = 3;
- var nCmdResult;
-
- var childProcess = new Array();
- childProcess[0] = "shellrestart.exe,true"; // Pixie Dust window
- childProcess[1] = "aolphx.exe,false"; // Schedual updates
-
- //======== Close AOL Execution ==========================================================
-
- function initCloseAOL() { // entry
- bStrauss = closeUtil.isAolStrauss();
- g_oAdp.Vars("CurrentADP") = "initCloseAOL";
- dispUtil.init();
- }
-
- function runCloseAOL(sBrowserState) {
- if (dispUtil.isValidPhase()) {
- if (sBrowserState == "visible") {
- closeUtil.closeBrowser();
- } else {
- runCloseChild();
- }
- }
- }
-
- function runCloseChild() {
- clearTimeout(excuteTimeout); // systray close timeout
-
- if (isChildProcess())
- excuteTimeout = setTimeout(runCloseChild, 4000);
- else
- setTimeout(finishClose, 3000);
- }
-
- //======== Execution utils ==============================================================
-
- function isChildProcess() {
- return closeUtil.killProcessBatch(childProcess);
- }
-
- function finishClose() {
-
- try {
- clearTimeout(excuteTimeout);
- } catch(e) {
- //alert(e.description);
- }
-
- if (closeUtil.isBrowserAlive()) {
- closeUtil.closeBrowser();
- } else {
- if (dispUtil.isValidPhase()) {
- g_oSys.getObj().StopWinWait(); // clears all events
- dispUtil.setMsg("idCloseAOLWait2", false);
- showScreen(idCloseAOLWait, {idBtnClose: dispUtil.goAbortRetry});
- idCloseAOLWait.all.idBtnClose.style.display = "";
- excuteTimeout = setTimeout(exitClose, 3000);
- }
- }
- }
-
- function exitClose() { //create a smooth switch to the flow
- dispUtil.setProgBarCss(true);
- excuteTimeout = setTimeout(navigateFlow, 1000);
- }
-
- //======== UI Util ======================================================================
-
- function userDisplay() {
-
- this.init = function() { // checks if display is needed or move directly to flow
- if (closeUtil.isBrowserAlive() || isChildProcess()) {
-
- if (bStrauss) {
- if (bSysTray) {
- this.setMsg("idCloseAOLWait2", false); //systray close
- } else {
- if (g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) != nApiCloseValid && !closeUtil.isOnline())
- this.setMsg("idCloseAOLWait3", false); //can't close client . verfing
- else
- this.setMsg("idCloseAOLWait", false); //client full close
- }
- } else {
- this.setMsg("idCloseAOLWait", false); //client full close
- }
-
-
- showScreen(idCloseAOLWait, {idBtnClose: dispUtil.goAbortRetry});
- idCloseAOLWait.all.idBtnClose.style.display = "";
- g_oSys.getObj().WaitForChildWindowCloseOrUnVisible("AOL","_AOL_Toolbar","",5000);
- } else {
- finishClose();
- }
- };
-
- this.setProgBarCss = function(bHide) {
- progObj = document.getElementById("ProgressBarContainer");
- progObj.style.top = "180";
- hideProgBar(bHide);
- };
-
- this.setMsg = function(msgId, bHide) {
- this.setProgBarCss(bHide);
- idMsgCloseAOLWait.innerHTML = getDsoMsg(msgId);
- };
-
- this.goAbortRetry = function() {
- bAbortedClose = true;
- g_oSys.getObj().StopWinWait(); // clears all events
-
- sLastEvent = "";
- g_oAdp.Vars("sRequestClose") = "";
- bWaitMsg = false;
- bProbedClient = false;
- nCmdResult = "";
-
- try {
- clearTimeout(excuteTimeout);
- } catch(e) {}
-
- g_oAdp.Vars("CurrentADP") = "goAbortRetry";
- sendStat("Abort");
- showScreen(idAbortRetry, {idBtnClose: chkExitWay, idBtnRestart: restartFix});
- };
-
- this.isValidPhase = function() {
- if (g_oAdp.Vars("CurrentADP").match(/goAbortRetry|goIntro|goEndAF/i) == null)
- return true;
- else
- return false;
- };
-
- }
-
- //======== Close Process Util ===========================================================
-
- function closeAolUtil() {
-
- this.killProcessBatch = function(sProcessBatch) { // closes / checks multiple process
- bAliveOrTerminated = false; // sets return value
- g_oProce.getObj().Exclude("%system%\\*"); // ignores process from %system%
- g_oProce.getObj().Exclude("*%windows%*"); // ignores process from %windows%
- g_oProce.getObj().Refresh;
-
- for (i=0;i<sProcessBatch.length;i++) {
- // gets data from array
- sThisProcess = sProcessBatch[i].substring(0, sProcessBatch[i].indexOf(","));
- bTerminate = (sProcessBatch[i].substring(sProcessBatch[i].indexOf(",") + 1, sProcessBatch[i].length));
-
- // loop through the process list
- for (a=0; a<g_oProce.getObj().Count; a++) {
- sCurrentProcess = g_oProce.getObj().Process(a); // current process
-
- if (sThisProcess.toLowerCase() == sCurrentProcess.LongBaseName().toLowerCase()) { // checks current process name
- if (bTerminate == "true")
- sCurrentProcess.Terminate(1,1000); // arguments force, time
-
- bAliveOrTerminated = true;
- }
- }
- }
-
- return bAliveOrTerminated;
- };
-
- this.closeBrowser = function() { // closes AOL client
-
- if (bStrauss) { // AOL Strauss close sequence
- if (g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) == nApiCloseValid || (this.isOnline() && g_oAdp.Vars("sRequestClose") != "TRUE")) {
- g_oAdp.Vars("sRequestClose") = "TRUE";
- nCmdResult = g_oSys.getObj().SendMessage("_AOL_EXAPI","",3630,0,0);
- }
- } else { // all other AOL versions close sequence
- if (g_oAdp.Vars("sRequestClose") != "TRUE") {
- sLastEvent = "default"; // resets the flag after probing AOL
- g_oAdp.Vars("sRequestClose") = "TRUE";
- g_oSys.getObj().SendMessage("AOL Frame25","*",0x0112,0xf060,0);
- }
- }
-
- g_oSys.getObj().WaitForChildWindowCloseOrUnVisible("AOL","_AOL_Toolbar","",10000); // AOL Brw. internal window
- };
-
- this.isBrowserAlive = function() {
- if (g_oAol.getObj().IsAolBrowserOpen() || g_oSys.getObj().FindChildWindow("AOL Frame25","*"))
- return true;
- else
- return false;
- };
-
- this.isAolStrauss = function() {
- if (parseInt(g_oAol.getObj().AolMajor) >= 4184)
- return true;
- else
- return false;
- };
-
- this.isOnline = function() {
- regDir = "Software\\America Online\\All";
-
- if (g_oReg.getObj().IsRegValue("Current", regDir, "topspeed.proxy.http")) {
- sOnlineStr = g_oReg.getObj().String("Current", regDir, "topspeed.proxy.http");
-
- if (sOnlineStr.match(/ie3/i)) //aol offline
- return false;
- else //aol online
- return true;
- } else { //aol offline
- return false;
- }
- };
-
-
- }
-
- //======== Aol window events (CallBacks) ================================================
-
- function eventHandler(sEvent, sWindow) {
- if (sWindow == "AOL_INTRO") { //intro text check
- g_oSys.getObj().StopWinWait(); // clears all events
-
- if (sEvent == "hidden") { //hidden mode
- bSysTray = true;
- goIntro(true);
- } else {
- goIntro(false);
- }
- }
-
- if (dispUtil.isValidPhase()) {
- if ((bStrauss && g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) == -1) && bWaitMsg) { // user closed AOL manually
- bWaitMsg = false;
- dispUtil.setMsg("idCloseAOLWait2", false);
- g_oSys.getObj().WaitForChildWindowOpen("AOL_SYS","_AOL_EXAPI","",20000);
- return;
- }
-
- if (((sLastEvent == "visible" && sEvent != "visible") || (bStrauss && g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) == nApiCloseValid)) && bWaitMsg) {
- bWaitMsg = false;
- dispUtil.setMsg("idCloseAOLWait", false);
- }
-
- if ((sEvent == "visible" && sLastEvent !="") || (bStrauss && !bWaitMsg && ((g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) != nApiCloseValid && g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) > 0 && !closeUtil.isOnline()) || (closeUtil.isOnline() && g_oAdp.Vars("sRequestClose") == "TRUE" && nCmdResult != nApiCloseValid)) )){
- bWaitMsg = true;
- dispUtil.setMsg("idCloseAOL", true);
- }
-
- runCloseAOL(sEvent);
- sLastEvent = sEvent;
- }
- }
-
- function sysTrayHandler(sState) {
- if (dispUtil.isValidPhase()) {
- if (sState == "visible")
- runCloseAOL("visible");
- else
- eventHandler("closed");
- }
- }
-
- function AdpSys_WaitForCloseOk(sValue) {
- eventHandler("closed", sValue);
- }
-
- function AdpSys_WaitForUnVisibleOk(sValue) {
- eventHandler("hidden", sValue);
- }
-
- function AdpSys_WaitForCloseTimeOut(sValue) {
- eventHandler("visible", sValue);
- }
-
- function AdpSys_WaitForOpenOk(sValue) { // AOL Strauss related, waits for systray to re-pop
- sysTrayHandler("visible", sValue);
- }
-
- function AdpSys_WaitForOpenTimeOut(sValue) {
- sysTrayHandler("closed", sValue);
- }